<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="shortcut icon" href="../images/favicon.png" type="image/png">

    <title>欢迎登录连连惠系统平台</title>

    <link href="../css/style.default.css" rel="stylesheet">
    <link href="../layui/css/layui.css" rel="stylesheet">


    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="../js/html5shiv.js"></script>
    <script src="../js/respond.min.js"></script>

    <![endif]-->
    <style>
        .nomargin{padding-bottom:20px;}
        .nomargin>div{width:50%;float:left;padding:10px;cursor: pointer;text-align: center;}
        .nomargin .active{border-bottom: 1px solid #1CAF9A;}
        .nobody>div{display: none;}
        .nobody>.active{display: block;}
    </style>
</head>
<body class="signin">
<section>
    <div class="signinpanel">
        <div class="row">
            <div class="col-md-5" style="float:none;margin:0 auto;">
                <form method="post" action="" onsubmit="return false;" style="background:#fff;">
                    <div class="nomargin">
                        <div class="active">密码登录</div>
                        <div>微信登录</div>

                    </div>
                    <div class="nobody">
                        <div class="active">
                            <div style="clear: both;"></div>
                            <input type="text" class="form-control uname" placeholder="用户名" name="username"/>
                            <input type="password" class="form-control pword" placeholder="密码" name="password"/>
                            <input type="text" class="form-control" placeholder="验证码"  name="captcha"/>
                            <div style="margin-top:10px;"><img id="captcha" src="/login/captcha" style="width:100%;"></div>
                            <button class="btn btn-success btn-block">登录</button>
                        </div>
                        <div>

                        </div>
                    </div>


                </form>
            </div><!-- col-sm-5 -->

        </div><!-- row -->



    </div><!-- signin -->

</section>


<script src="../js/jquery-1.11.1.min.js"></script>
<script src="../js/jquery-migrate-1.2.1.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/modernizr.min.js"></script>
<script src="../js/jquery.sparkline.min.js"></script>
<script src="../js/jquery.cookies.js"></script>
<script src="../js/toggles.min.js"></script>
<script src="../js/retina.min.js"></script>
<script src="../js/custom.js"></script>
<script src="../js/commen.js" charset="utf-8"></script>
<!--<script src="../layui/lay/modules/layer.js"></script>-->
<link href="../css/ley.dialog.css" rel="stylesheet">
<script src="../js/ley.dialog.js?t={{$version}}"></script>


<script>
    var timer = null;
    var is_check = false;
    function logincheck()
    {
        clearTimeout(timer);
        if(is_check === false)
        {
            return false;
        }
        timer = setTimeout(function(){
            AjaxCommen("GET","/login/logincheck",{},function (result) {
                logincheck();
            });
        },3000);
    }
    function refresh_captcha()
    {
        var nowDate = new Date().getTime();
        $("#captcha").attr("src","/login/captcha?t="+nowDate);
    }
    jQuery(document).ready(function(){
        $("#captcha").click(function () {
            refresh_captcha();
        });
        $(".nomargin>div").click(function () {
            var index = $(this).index();
            is_check = false;
            if(index === 1)
            {
                var text = '<img src="/login/weixin_token?t='+(new Date().getTime())+'" width="100%" >';
                text += '<div style="text-align: center;">未绑定可在登录后右上角绑定微信</div>';
                $(".nobody>div").eq(index).html(text);
                is_check = true;
                logincheck();
            }
            $(".nomargin>div").removeClass("active").eq(index).addClass("active");
            $(".nobody>div").removeClass("active").eq(index).addClass("active");

        });
        $(".btn-success").click(function () {
            var username = $("input[name='username']").val();
            var password = $("input[name='password']").val();
            var captcha = $("input[name='captcha']").val();
            if(username.length < 1)
            {
                openMsg("请输入用户名");
                return false;
            }
            if(password.length < 1)
            {
                openMsg("请输入密码");
                return false;
            }
            AjaxCommen("GET","/login/login",{username:username,password:password,captcha:captcha},function (result) {
                if (!result.error)
                {
                    openMsg(result.msg);

                }
                refresh_captcha();
            });
        });
        // Please do not use the code below
        // This is for demo purposes only
//        var c = jQuery.cookie('change-skin');
//        if (c && c == 'greyjoy') {
//            jQuery('.btn-success').addClass('btn-orange').removeClass('btn-success');
//        } else if(c && c == 'dodgerblue') {
//            jQuery('.btn-success').addClass('btn-primary').removeClass('btn-success');
//        } else if (c && c == 'katniss') {
//            jQuery('.btn-success').addClass('btn-primary').removeClass('btn-success');
//        }
    });
</script>

</body>
</html>
